Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement device-side RNG #380

Merged
merged 6 commits into from
Dec 1, 2023
Merged

Implement device-side RNG #380

merged 6 commits into from
Dec 1, 2023

Conversation

utkarsh530
Copy link
Contributor

using AMDGPU
using Random
function kernel()
    Random.seed!(123)
    return nothing
end
@roc kernel()
julia> @roc kernel()
ERROR: GPU compilation of kernel #kernel() failed
KernelError: kernel returns a value of type `Union{}`

Make sure your kernel function ends in `return`, `return nothing` or `nothing`.
If the returned value is of type `Union{}`, your Julia code probably throws an exception.
Inspect the code with `@device_code_warntype` for more details.

Stacktrace:
 [1] check_method(job::GPUCompiler.CompilerJob)
   @ GPUCompiler ~/.julia/packages/GPUCompiler/kb6yJ/src/validation.jl:41
 [2] macro expansion
   @ ~/.julia/packages/TimerOutputs/LHjFw/src/TimerOutput.jl:253 [inlined]
 [3] macro expansion
   @ ~/.julia/packages/GPUCompiler/kb6yJ/src/driver.jl:152 [inlined]
 [4] emit_julia(job::GPUCompiler.CompilerJob)
   @ GPUCompiler ~/.julia/packages/GPUCompiler/kb6yJ/src/utils.jl:83
 [5] rocfunction_compile(job::GPUCompiler.CompilerJob)
   @ AMDGPU.Compiler ~/.julia/dev/AMDGPU/src/compiler/codegen.jl:181
 [6] cached_compilation(cache::Dict{UInt64, Any}, job::GPUCompiler.CompilerJob, compiler::typeof(AMDGPU.Compiler.rocfunction_compile), linker::typeof(AMDGPU.Compiler.rocfunction_link))
   @ GPUCompiler ~/.julia/packages/GPUCompiler/kb6yJ/src/cache.jl:90
 [7] rocfunction(f::typeof(kernel), tt::Type; name::Nothing, device::ROCDevice, global_hooks::NamedTuple{(), Tuple{}})
   @ AMDGPU.Compiler ~/.julia/dev/AMDGPU/src/compiler/codegen.jl:165
 [8] rocfunction(f::typeof(kernel), tt::Type)
   @ AMDGPU.Compiler ~/.julia/dev/AMDGPU/src/compiler/codegen.jl:154
 [9] top-level scope
   @ ~/.julia/dev/AMDGPU/src/highlevel.jl:430

@utkarsh530
Copy link
Contributor Author

Intended to Fix #378

@jpsamaroo jpsamaroo linked an issue Feb 8, 2023 that may be closed by this pull request
@jpsamaroo jpsamaroo changed the title Attempt to Fix Random call inside the kernel Implement device-side RNG Feb 8, 2023
@utkarsh530 utkarsh530 closed this Feb 9, 2023
@utkarsh530 utkarsh530 reopened this Feb 9, 2023
@williamfgc
Copy link

williamfgc commented Jul 7, 2023

@utkarsh530 @jpsamaroo thanks for the PR! Is there anything on my side to help merge this? CI error is related to NNLib.jl/#482.

@jpsamaroo jpsamaroo force-pushed the u/random branch 2 times, most recently from 3214731 to 53852d0 Compare November 15, 2023 18:17
@vchuravy vchuravy requested a review from pxl-th November 28, 2023 19:48
src/device/random.jl Outdated Show resolved Hide resolved
src/device/random.jl Outdated Show resolved Hide resolved
src/device/random.jl Outdated Show resolved Hide resolved
@pxl-th pxl-th merged commit 10b5fa9 into JuliaGPU:master Dec 1, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for rand from Julia Base on device code
5 participants